﻿using System;
using System.Reflection;

namespace Lucene.Linq.Mapping
{
    /// <summary>
    /// Details a field to property mapping
    /// </summary>
    public class FieldDetails
    {
        /// <summary>
        /// The name of the field
        /// </summary>
        public string Name
        {
            get
            {
                return Field == null
                           ? Property.Name
                           : (String.IsNullOrEmpty(Field.Name)
                                  ? Property.Name
                                  : Field.Name);
            }
        }

        internal string SortName
        {
            get { return "s_" + Name; }
        }


        /// <summary>
        /// The underlying class property
        /// </summary>
        public PropertyInfo Property { get; set; }

        /// <summary>
        /// The decorating field attribute
        /// </summary>
        public FieldAttribute Field { get; set; }
    }
}